package com.tianzj.mvc.util;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

import com.tianzj.mvc.system.pojo.SysUser;
public class SessionUser {

	/**
	 * 获取当前用户
	 * @return 取不到返回 new User()
	 */
	public static SysUser getUser(){
		Subject subject = SecurityUtils.getSubject();
		SysUser sysUser = (SysUser) subject.getPrincipal();
		if(sysUser==null){
			sysUser = (SysUser) subject.getSession().getAttribute("sessionUser");
		}
		return sysUser;
	}
	
}
